<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="include :: header('新增党风廉政建设外宣稿件情况统计')" />
</head>

<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-templatetable3-add">
            <input id="progressId" name="workProgress.progressId" th:value="${workProgress.progressId}" type="hidden">
			<input id="status" name="workProgress.status" th:value="${workProgress.status}" type="hidden">
            <h4 class="form-header h4">党风廉政建设外宣稿件情况统计</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus">
                            增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="delColumn()"><i class="fa fa-minus">
                            删除</i></button>
                    <div class="col-sm-12 select-table table-bordered">
                        <table id="bootstrap-table"></table>
                    </div>
                    </br>
                    <p style="color: red">备注：填表说明：请每月最后一天前填报本年度累计情况。</p>
                    <p>外宣稿件统计范围：</p>
                    <p>一、纪检监察官方媒体平台</p>
                    <p> （一）中央纪委媒体：中央纪委报刊（中国纪检监察报、中国纪检监察杂志、党风廉政建设）、中央纪委网站、中央纪委APP</p>
                    <p> （二）省纪委媒体：“廉洁四川”网站、 “廉洁四川”微信、“廉洁四川”电视栏目</p>
                    <p> （三）市纪委自办媒体：“廉洁宜宾”微信</p>
                    <p>二、综合媒体报刊平台</p>
                    <p> （一）国家级主流媒体：人民日报、新华社、求是、光明日报、经济日报、中国日报、中央人民广播电台、中央电视台、中国青年报、法制日报等中央媒体（不含网、微、客户端）</p>
                    <p> （二）省级主流媒体：四川日报、四川广播电视台、四川广播电台、四川党的建设、华西都市报、廉政瞭望（廉政瞭望只统计“廉洁四川”专栏下面的稿件，资讯快递栏不计分）等省级媒体（不含网、微、客户端）
                    </p>
                    <p> （三）市级主流媒体：宜宾日报、宜宾广播电视台、宜宾晚报等市级媒体（不含网、微、客户端）</p>
                    <div class="row">
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">填报单位：</label>
                                <div class="form-control-static" th:text="${workProgress.receiveDept}"></div>
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">填报人：</label>
                                <div class="form-control-static" th:text="${workProgress.receiveUser}"></div>
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">填报时间：</label>
                                <div class="form-control-static" th:text="${today}"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
        <div class="row">
			<div class="col-sm-offset-5 col-sm-10">
				<button type="button" class="btn btn-sm btn-success" onclick="submitHandler('3')"><i
						class="fa fa-plus"></i>保 存</button>&nbsp;
				<button type="button" class="btn btn-sm btn-primary" onclick="submitHandler('4')"><i
						class="fa fa-check"></i>上 报</button>&nbsp;
				<button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i
						class="fa fa-reply-all"></i>关 闭</button>
			</div>
		</div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "work/templatetable3";

        $(function () {
            var options = {
                url: prefix + "/list",
                queryParams: {progressId: $('#progressId').val()},
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [
                    [{
                        field: 'index',
                        checkbox: true,
                        rowspan: 2,
                        align: 'center',
                        valign: 'middle'
                    }, {
                        field: 'val1',
                        title: '序号',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var columnIndex = $.common.sprintf("<input class='form-control' type='hidden' name='workTemplateTable3List[%s].val1' value='%s'>", index, $.table.serialNumber(index));
                            return columnIndex + $.table.serialNumber(index);
                        }
                    }, {
                        title: '采用时间',
                        align: 'center',
                        colspan: 2
                    }, {
                        field: 'val4',
                        title: '题目',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable3List[%s].val4' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        title: '所属媒体',
                        align: 'center',
                        colspan: 2
                    }, {
                        field: 'val7',
                        title: '版面',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable3List[%s].val7' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        field: 'val8',
                        title: '类别',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable3List[%s].val8' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        field: 'val9',
                        title: '网络连接',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable3List[%s].val9' value='%s'>", index, value);
                            return html;
                        }
                    }],
                    [{
                        field: 'val2',
                        align: 'center',
                        title: '月',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable3List[%s].val2' value='%s'>", index, value);
                            return html;
                        }
                    },
                    {
                        field: 'val3',
                        align: 'center',
                        title: '日',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable3List[%s].val3' value='%s'>", index, value);
                            return html;
                        }
                    },
                    {
                        field: 'val5',
                        align: 'center',
                        title: '纪检监察官方媒体平台',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable3List[%s].val5' value='%s'>", index, value);
                            return html;
                        }
                    },
                    {
                        field: 'val6',
                        align: 'center',
                        title: '综合媒体报刊平台',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable3List[%s].val6' value='%s'>", index, value);
                            return html;
                        }
                    }]
                ]
            };
            $.table.init(options);
        });

      /*  /!* 主子表-提交 *!/
        function submitHandler(index, layero) {
            var data = $("#form-templatetable3-add").serializeArray();
            $.operate.save(prefix + "/add", data);
        }*/


        function submitHandler(status) {
            if ($.validate.form()) {
                var data = $("#form-templatetable3-add").serializeArray()
                $('#status').val(status)
                console.log("data:" + JSON.toString(data) + data);
                console.log("status" + status);
                $.operate.save(prefix + "/add", $("#form-templatetable3-add").serializeArray());
            }
        }

        function editColumn() {
            var dataColumns = [{
                checkbox: false,
            }, {
                field: 'val1',
                title: '序号'
            }, {
                field: 'val2',
                align: 'center',
                title: '月',
            },
            {
                field: 'val3',
                align: 'center',
                title: '日',
            }, {
                field: 'val4',
                title: '题目',
            }, {
                field: 'val5',
                align: 'center',
                title: '纪检监察官方媒体平台',
            },
            {
                field: 'val6',
                align: 'center',
                title: '综合媒体报刊平台',
            }, {
                field: 'val7',
                title: '版面',
            }, {
                field: 'val8',
                title: '类别',
            }, {
                field: 'val9',
                title: '网络连接',
            }]
            var params = new Array();
            var data = $("#" + table.options.id).bootstrapTable('getData');
            var count = data.length;
            for (var dataIndex = 0; dataIndex < count; dataIndex++) {
                var columns = $('#' + table.options.id + ' tr[data-index="' + dataIndex + '"] td');
                var obj = new Object();
                for (var i = 0; i < columns.length; i++) {
                    var inputValue = $(columns[i]).find('input');
                    var selectValue = $(columns[i]).find('select');
                    var key = dataColumns[i].field;
                    if ($.common.isNotEmpty(inputValue.val())) {
                        obj[key] = inputValue.val();
                    } else if ($.common.isNotEmpty(selectValue.val())) {
                        obj[key] = selectValue.val();
                    } else {
                        obj[key] = "";
                    }
                }
                var item = data[dataIndex];
                var extendObj = $.extend({}, item, obj);
                params.push({ index: dataIndex, row: extendObj });
            }
            $("#" + table.options.id).bootstrapTable("updateRow", params);
        }
        function delColumn(column) {
            editColumn();
            var subColumn = $.common.isEmpty(column) ? "index" : column;
            var ids = $.table.selectColumns(subColumn);
            if (ids.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            $("#" + table.options.id).bootstrapTable('remove', { field: subColumn, values: ids });
        }
        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            console.log($("#" + table.options.id).bootstrapTable('getData'))
            editColumn();
            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: false,
                    val1: "",
                    val2: "",
                    val3: "",
                    val4: "",
                    val5: "",
                    val6: "",
                    val7: "",
                    val8: "",
                    val9: "",
                }
            });
        }
    </script>
</body>

</html>